package shared.pojo.mission

import shared.Pojo._
import shared.implicits.Implicits._
import shared.tool.DefaultPickle
import upickle.default._

/** Created by yz on 15/5/2023
  */
object CorHeatmapPlot extends CorHeatmapPlotT {

  def pngFileNamePrefixIn = {
    s"Correlation_Heatmap"
  }

  def pngFileNamePrefix(idStr: String) = {
    if (idStr.nonBlank) {
      s"${idStr}/${pngFileNamePrefixIn}"
    } else {
      s"${pngFileNamePrefixIn}"
    }
  }

  def configFileName = {
    s"${name}.json"
  }

  case class LayoutData(
      rowCluster: String = "T",
      rowClusterMethod: String = "complete",
      colCluster: String = "T",
      colClusterMethod: String = "complete",
      width: String = "0",
      height: String = "0",
      rowTreeHeight: String = "10",
      colTreeHeight: String = "10"
  )

  object LayoutData {
    implicit val rw = macroRW[LayoutData]
    implicit val defaultRw = DefaultPickle.macroRW[LayoutData]
  }

  val customColors = List("#1E90FF", "#FFFFFF", "#E41A1C")

  case class ColorData(
      colorsStr: String = customColors.mkString(":"),
      customColors: List[String] = customColors,
      naColor: String = "#808080"
  )

  object ColorData {
    implicit val rw = macroRW[ColorData]
    implicit val defaultRw = DefaultPickle.macroRW[ColorData]
  }

  case class FontData(
      fontFamily: String = "Times",
      showColName: String = "T",
      xFont: String = "6",
      xRotate: String = "90",
      showRowName: String = "T",
      yRotate: String = "0",
      xTitleFont: String = "11",
      yFont: String = "6",
      yTitleFont: String = "11",
      mainTitle: String = "",
      mainTitleFont: String = "13",
      legendFont: String = "12",
      legendTitle: String = "",
      legendTitleFont: String = "12"
  )

  object FontData {
    implicit val rw = macroRW[FontData]
    implicit val defaultRw = DefaultPickle.macroRW[FontData]
  }

  case class Request(
      id: Int = 0,
      idStr: String = "",
      kind: String = s"${name}",
      layout: LayoutData = LayoutData(),
      color: ColorData = ColorData(),
      font: FontData = FontData()
  )

  object Request {
    implicit val rw = macroRW[Request]
    implicit val defaultRw = DefaultPickle.macroRW[Request]
  }

}
